/*!
    \file    i2c_port.h
    \brief   definitions of platform port for the gd30ad3x40
    
    \version 2024-10-08, V1.0.0, firmware for GD30AD3x40
*/

#ifndef __I2C_PORT__H
#define __I2C_PORT__H

#include "gd32f30x_i2c.h"
#include "gd32f30x_rcu.h"
#include "gd32f30x_gpio.h"
#include "gd32f30x_exti.h"
#include "gd32f30x_misc.h"

#define I2C0_SPEED                      100000
#define I2C0_SLAVE_ADDRESS7             0x90
#define DUT_SLAVE_ADDRESS7_GND          0x90
#define DUT_SLAVE_ADDRESS_VDD           0x92


/* initialize I2C GPIO */
void ad3x40_i2c_gpio_init(void);
/* initialize I2C */
void ad3x40_i2c_init(void);
/* disable I2C */
void ad3x40_i2c_disable(void);
/* I2C master as transmitter start */
void ad3x40_i2c_tx_start(void);
/* I2C master as transmitter transmit a byte */
void ad3x40_i2c_tx_byte(uint8_t tx_byte);
/* I2C master as transmitter stop */
void ad3x40_i2c_tx_stop(void);
/* I2C master as receiver start */
void ad3x40_i2c_rx_start(void);
/* I2C master as receiver receive a byte */
uint8_t ad3x40_i2c_rx_byte(void);
/* I2C master as receiver receive a byte ack */
uint8_t ad3x40_i2c_rx_byte_ack(void);
/* I2C master as receiver stop */
void ad3x40_i2c_rx_stop(void);

#endif //__I2C_PORT__H
